<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">
		<!-- <fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">项目名称</label>
						<div class="layui-input-inline">
							<input type="text" name="item"  autocomplete="off" placeholder="请输入项目名称" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" class="layui-btn layui-btn-primary"  onclick="get_seek()"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset> -->
		
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilters"></table>
		<script type="text/html" id="toolbarDemo">
			<div class="layui-btn-container">
				<button class="layui-btn layui-btn-success layui-btn-sm data-add-btn" lay-event="items">添加消耗</button>
			</div>
		</script>
		<script type="text/html" id="currentTableBar"> 
  			<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		</script>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>

	var items_id = {$Request.get.items_id};
	var op_account_id = {$Request.get.op_account_id};
	var $,form,table,laydate;
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		$ = layui.jquery , form = layui.form , table = layui.table , laydate = layui.laydate
		pageLoading();
		table.render({
			elem: '#currentTableId',
			id:'consume_list',
			url: '{:url("consume_list")}?t=json',
			method : 'post',
			toolbar: '#toolbarDemo',
			where:{items_id:items_id,op_account_id:op_account_id},
			loading:false,
			cols: [[
				{ field: 'time', title: '时间',templet: function(d){
			          return date("Y-m-d",d.time)
			    }},
                { field: 'currency', title: '消耗'},
                { field: 'num', title: '表单数量'},
				{ field: 'balance', title: '昨日余额'},
                { field: 'proof_url', title: '图片',templet: function(d){
			          return d.proof_url?'<img src="'+d.proof_url+'">':''
			    }},
			    { title: '操作', minWidth: 60, fixed: 'right', toolbar: '#currentTableBar',align:'center'}
			]],
			limit: 30,
			page: true,
			skin: 'line',
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});
		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(currentTableFilters)', function (obj) {
			switch (obj.event) {
				case 'items':
					 window.parent.get_consume(items_id,op_account_id);
				break;
				
			}
			
		});
		table.on('tool(currentTableFilters)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					 window.parent.get_save(data.id)
				break;
			}
			
		});
		//监听行单击事件
		/* table.on('row(currentTableFilters)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			}); */

	});
	function get_load(){
		pageLoading();
		table.reload('consume_list', {
			  url: '{:url("consume_list")}?t=json',
			});
	}
	
	
	
</script>

</body>
</html>